package wh.bos.web.action.base;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Controller;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;

import wh.bos.domain.base.Standard;
import wh.bos.service.base.StandardService;
import wh.bos.web.action.BaseAction;

@ParentPackage("json-default")
@Namespace("/")
@Controller
@Scope("prototype")
public class StandardAction extends BaseAction<Standard> {

	
	//注入Service对象
	@Autowired
	private StandardService standardService;
	
	//添加或者修改收派管理
	@Action(value="standard_save",results={@Result(name="success",type="redirect",
			location="./pages/base/standard.html")})
	public String save(){
		standardService.save(model);
		return SUCCESS;
	}
	
	//分页列表查询
	@Action(value="standard_pageQuery",results={@Result(name="success",type="json")})
	public String pageQuery(){
		//调用业务层,查询数据
		Pageable pageable = new PageRequest(page-1, rows);
		Page<Standard> pageDate = standardService.findPageDate(pageable);
		
		//返回客户端数据
		pushPageDateToValueStack(pageDate);
		
		return SUCCESS;
	}
	
	//查询所有收派数据
	@Action(value="standard_findAll",results={@Result(name="success",type="json")})
	public String findAll(){
		List<Standard> standards = standardService.findAll();
		ActionContext.getContext().getValueStack().push(standards);
		return SUCCESS;
		
	}
}

